﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using CoDbObject;
using Colligate;
using SZJT.Utility.DataSource;

namespace Colligate.DataSource.DriverTraining.Business.Student
{
    class DataNode_BusinessStudentInfo : BaseDataTree
    {
        private const string DATATYPE_STUDENT_INFO = "BizStudentInfo";
        private const string DATATYPE_STUDENT_LAST_INFO = "BizStudentInfoLastOne";
        private const string DATATYPE_STUDENT_QUERY = "BizStudentInfoQuery";
        private const string DATATYPE_STUDENT_BYID = "BizStudentInfoByID";
        private const string DATATYPE_STUDENT_CHGPWD = "BizStudentInfoChangePwd";
        private const string DATATYPE_GET_STUDENT_BY_FINGER = "BizStudentInfoByFingerprinter";

        public DataNode_BusinessStudentInfo(string taskGuid, IDataSourceLayer dataLayer, IDataService dataService)
            : base(taskGuid, dataLayer, dataService)
        {
            _dataTypeList[DataTypeCategory.SET_DATA_LIST] = new string[] { DATATYPE_STUDENT_INFO };
            _dataTypeList[DataTypeCategory.GET_DATA_LIST] = new string[] { DATATYPE_STUDENT_INFO, 
                DATATYPE_STUDENT_LAST_INFO, DATATYPE_STUDENT_BYID, DATATYPE_GET_STUDENT_BY_FINGER};
            _dataTypeList[DataTypeCategory.TRANSFORM_LIST] = new string[] { DATATYPE_STUDENT_QUERY };
            _dataDefine = new BusinessStudentInfo(dataLayer);
        }

        #region Public Method
        public override int DeleteData(OUDataInfo userInfo, string dataGuid, string dataType)
        {
            int result = 1001;
            switch (dataType)
            {
                case DATATYPE_STUDENT_INFO:
                    result = DeleteStudentInfo(userInfo, dataGuid);
                    break;
            }
            return result;
        }

        public override int SetData(OUDataInfo userInfo, string dataGuid, string dataType, System.Xml.XmlNode xmlData)
        {
            int result = 1001;
            switch (dataType)
            {
                case DATATYPE_STUDENT_INFO:
                    result = SetStudentInfo(userInfo, dataGuid, xmlData);
                    break;
                case DATATYPE_STUDENT_CHGPWD:
                    result = ChangeStudentPassword(userInfo, dataGuid, xmlData);
                    break;
            }
            return result;
        }

        public override XmlNode GetData(OUDataInfo UserInfo, string DataGuid, string DataType)
        {
            XmlNode ResultInfo = null;
            switch (DataType)
            {
                case DATATYPE_STUDENT_INFO:
                    ResultInfo = GetStudentInfo(UserInfo, DataGuid);
                    break;
                case DATATYPE_STUDENT_LAST_INFO:
                    ResultInfo = GetLastStudentInfo(UserInfo, DataGuid);
                    break;
                case DATATYPE_STUDENT_BYID:
                    ResultInfo = GetStudentInfoByID(UserInfo, DataGuid);
                    break;
                case DATATYPE_GET_STUDENT_BY_FINGER:
                    ResultInfo = GetStudentInfoByFinger(UserInfo, DataGuid);
                    break;
            }

            return ResultInfo;
        }

        public override XmlNode TransformData(OUDataInfo UserInfo, string DataType, XmlNode XmlParam)
        {
            XmlNode ResultInfo = null;
            switch (DataType)
            {
                case DATATYPE_STUDENT_QUERY:
                    ResultInfo = GetStudentList(UserInfo, XmlParam);
                    break;
            }

            return ResultInfo;
        }


        #endregion

        #region protected Method

        #region Set Data

        //<Document TaskGuid="{智慧驾培学事管理系统任务标识}" DataGuid="{学员信息标识}" DataType="BizStudentInfo">
        //<StudentGuid Type="GUID" Mandatory="是">{学员信息标识}</StudentGuid>
        //<StudentName Type="TEXT" Mandatory="是" Length="10">{学员姓名}</StudentName>
        //<StudentSex Type="TEXT" Mandatory="是" Length="1">{学员性别[F:女性|M:男性]}</StudentSex>
        //<StudentIdType Type="TEXT" Mandatory="是" Length="6">{学员证件类型[身份证|军官证|护照]}</StudentIdType>
        //<StudentIdCode Type="TEXT" Mandatory="是" Length="18">{学员证件号}</StudentIdCode>
        //<StudentAge Type="LONG" Mandatory="是" Length="0">{学员年龄}</StudentAge>
        //<StudentID Type="TEXT" Mandatory="是" Length="8">{学员号}</StudentID>
        //<StudentMobile Type="TEXT" Mandatory="是" Length="15">{学员手机号}</StudentMobile>
        //<StudentMail Type="TEXT" Mandatory="否" Length="50">{学员邮箱}</StudentMail>
        //<StudentAccount Type="TEXT" Mandatory="是" Length="15">{学员帐号}</StudentAccount>
        //<StudentPassword Type="TEXT" Mandatory="是" Length="20">{学员密码}</StudentPassword>
        //<StudentStatus Type="TEXT" Mandatory="是" Length="10">{学员状态[在学|已毕业|已退学]}</StudentStatus>
        //</Document>
        protected int SetStudentInfo(OUDataInfo userInfo, string studentGuid, XmlNode XmlData)
        {
            //if (!CheckPrivilege(UserInfo, "操作成员"))
            //    return -3;


            IDBDataObject InfoData = (_dataDefine as BusinessStudentInfo).GetStudentInfoData(studentGuid);

            bool isNewStudent = (InfoData["ID"] == "0");
            string studentID = XmlNodeManage.GetSubValue(XmlData, "StudentID");
            string studentPassword = studentID.Length >= 6 ? studentID.Substring(studentID.Length - 6, 6) : studentID;
            
            int result = 0;
            InfoData["fStudentGuid"] = XmlNodeManage.GetSubValue(XmlData, "StudentGuid");
            InfoData["fStudentName"] = XmlNodeManage.GetSubValue(XmlData, "StudentName");
            InfoData["fStudentSex"] = XmlNodeManage.GetSubValue(XmlData, "StudentSex");
            InfoData["fStudentType"] = XmlNodeManage.GetSubValue(XmlData, "StudentType");
            InfoData["fStudentID"] = XmlNodeManage.GetSubValue(XmlData, "StudentID");
            InfoData["fStudentAge"] = XmlNodeManage.GetSubValue(XmlData, "StudentAge");
            InfoData["fStudentCode"] = XmlNodeManage.GetSubValue(XmlData, "StudentCode");
            InfoData["fStudentMobile"] = XmlNodeManage.GetSubValue(XmlData, "StudentMobile");
            InfoData["fStudentMail"] = XmlNodeManage.GetSubValue(XmlData, "StudentMail");
            if (isNewStudent)
            {
                InfoData["fStudentAccount"] = studentPassword;
            }
            InfoData["fStudentPassword"] = XmlNodeManage.GetSubValue(XmlData, "StudentPassword");
            InfoData["fStudentStatus"] = XmlNodeManage.GetSubValue(XmlData, "StudentStatus");
            InfoData["fSchoolGuid"] = XmlNodeManage.GetSubValue(XmlData, "SchoolGuid");
            InfoData["fSchoolName"] = XmlNodeManage.GetSubValue(XmlData, "SchoolName");

            result = InfoData.SaveData() ? 0 : 4;

            if (isNewStudent)
            {
                XmlNodeManage.SetSubValue(XmlData, "StudentPassword", "TEXT", studentPassword);
                result = result | CreateStudentLoginAccount(userInfo, studentGuid, XmlData);
            }
            return result;
        }

        protected int DeleteStudentInfo(OUDataInfo userInfo, string studentGuid)
        {
            //if (!CheckPrivilege(UserInfo, "操作成员"))
            //    return -3;


            IDBDataObject InfoData = (_dataDefine as BusinessStudentInfo).GetStudentInfoData(studentGuid);

            return InfoData.DeleteData() ? 0 : 1;
        }

        //<Document TaskGuid = "组件标识" DataGuid = "人员标识" DataType = "Member">
        //    <Guid Type = "GUID">人员标识</Guid>
        //    <Name Type = "TEXT">姓名</Name>
        //    <BranchGuid Type = "GUID">部门标识</BranchGuid>
        //    <BranchName Type = "GUID">部门名称</BranchName>
        //    <Telephone Type = "TEXT">联系电话</Telephone>
        //    <Handphone1 Type = "TEXT">移动电话1</Handphone1>
        //    <Handphone2 Type = "TEXT">移动电话2</Handphone2>
        //    <EMail Type = "TEXT">邮箱</EMail>
        //    <Order Type = "LONG">序号</Order>
        //</Document>
        //<Document TaskGuid = "组件标识" DataGuid = "账户标识" DataType = "Account">
        //    <Guid Type = "GUID">组织单元标识</Guid>
        //    <AccountName Type = "TEXT">账户名</AccountName>
        //    <Password Type = "TEXT">密码</Password>
        //    <Type Type = "TEXT">账户类型[Member|Platform]</Type>
        //    <Name Type = "TEXT">组织单元名称</Name>
        //    <IsEvection Type= "LOGICAL">是否外出【true：外出|false：在岗】</IsEvection>
        //    <Status Type = "LOGICAL">账户状态【true：启用|false：禁用】</Status>
        //</Document>
        protected int CreateStudentLoginAccount(OUDataInfo userInfo, string studentGuid, XmlNode xmlData)
        {
            string taskGuidOrg = "0690f841-7773-445c-9f48-a7a0427686d5";

            XmlNode xmlMemberData = XmlNodeManage.GetDocumentNode(taskGuidOrg, studentGuid, "Member");
            XmlNodeManage.SetSubValue(xmlMemberData, "Guid", "GUID", XmlNodeManage.GetSubValue(xmlData, "StudentGuid"));
            XmlNodeManage.SetSubValue(xmlMemberData, "Name", "TEXT", XmlNodeManage.GetSubValue(xmlData, "StudentName"));
            XmlNodeManage.SetSubValue(xmlMemberData, "BranchGuid", "TEXT", "G_Student");
            XmlNodeManage.SetSubValue(xmlMemberData, "BranchName", "TEXT", "学员");
            XmlNodeManage.SetSubValue(xmlMemberData, "Telephone", "TEXT", XmlNodeManage.GetSubValue(xmlData, "StudentMobile"));
            XmlNodeManage.SetSubValue(xmlMemberData, "EMail", "LOGICAL", XmlNodeManage.GetSubValue(xmlData, "StudentMail"));
            XmlNodeManage.SetSubValue(xmlMemberData, "Order", "LONG", "1");

            int result = (_dataService.SetTaskData(taskGuidOrg, studentGuid, "Member", xmlMemberData) == 0 ? 0 : 2);

            XmlNode xmlAccountData = XmlNodeManage.GetDocumentNode(taskGuidOrg, studentGuid, "Account");
            XmlNodeManage.SetSubValue(xmlAccountData, "Guid", "GUID", XmlNodeManage.GetSubValue(xmlData, "StudentGuid"));
            XmlNodeManage.SetSubValue(xmlAccountData, "AccountName", "TEXT", XmlNodeManage.GetSubValue(xmlData, "StudentAccount"));
            XmlNodeManage.SetSubValue(xmlAccountData, "Password", "TEXT", XmlNodeManage.GetSubValue(xmlData, "StudentPassword"));
            XmlNodeManage.SetSubValue(xmlAccountData, "Type", "TEXT", "User");
            XmlNodeManage.SetSubValue(xmlAccountData, "Name", "TEXT", "Student");
            XmlNodeManage.SetSubValue(xmlAccountData, "IsEvection", "LOGICAL", "false");
            XmlNodeManage.SetSubValue(xmlAccountData, "Status", "LOGICAL", "true");

            result += (_dataService.SetTaskData(taskGuidOrg, studentGuid, "Account", xmlAccountData) == 0 ? 0 : 1);
            return result;
        }

        //<Document TaskGuid="PlatformInfoGuid" DataGuid="用户标识" DataType="ChangePassword">
        //  <Guid Type="TEXT">用户标识</Guid>
        //  <UserName Type="TEXT">用户名称</UserName>
        //  <OldPassword Type="TEXT">旧口令</OldPassword>
        //  <NewPassword Type="TEXT">新口令</NewPassword>
        //</Document>
        protected int ChangeStudentLoginPassword(OUDataInfo userInfo, string studentGuid, XmlNode xmlData)
        {
            string taskGuidOrg = "0690f841-7773-445c-9f48-a7a0427686d5";

            XmlNode xmlChgPwdData = XmlNodeManage.GetDocumentNode(taskGuidOrg, studentGuid, "Member");
            XmlNodeManage.SetSubValue(xmlChgPwdData, "Guid", "GUID", XmlNodeManage.GetSubValue(xmlData, "StudentGuid"));
            XmlNodeManage.SetSubValue(xmlChgPwdData, "Name", "TEXT", XmlNodeManage.GetSubValue(xmlData, "StudentName"));
            XmlNodeManage.SetSubValue(xmlChgPwdData, "OldPassword", "TEXT", XmlNodeManage.GetSubValue(xmlData, "OldPassword"));
            XmlNodeManage.SetSubValue(xmlChgPwdData, "NewPassword", "TEXT", XmlNodeManage.GetSubValue(xmlData, "NewPassword"));

            int result = _dataService.SetTaskData(taskGuidOrg, studentGuid, "ChangePassword", xmlChgPwdData);
            return result;
        }

        #region 更新学员密码
        //<!-- 应用标识：智慧驾培学事管理系统 -->
        //<!-- 模块分类：驾校运营 -->
        //<!-- 功能分类：学员管理 -->
        //<!-- 分类序号：1051 -->
        //<!-- 数据编号：ZHJP-BUSINESS-STUDENT-1051 -->
        //<!-- 数据类型：复合数据 -->
        //<!-- 数据名称：更新学员密码 -->
        //<!-- 数据代码：BizStudentInfoChangePwd -->
        //<!-- 数据说明：更新学员的密码，需提供旧密码以供验证，后台执行为设置组织机构的登录帐号密码 -->
        //<Document TaskGuid="{智慧驾培学事管理系统任务标识}" DataGuid="{更新学员密码标识}" DataType="BizStudentInfoChangePwd">
        //    <StudentGuid Type="GUID" Mandatory="是">{更新学员密码标识}</StudentGuid>
        //    <StudentName Type="TEXT" Mandatory="是" Length="10">{学员姓名}</StudentName>
        //    <OldPassword Type="TEXT" Mandatory="是" Length="20">{旧密码}</OldPassword>
        //    <NewPassword Type="TEXT" Mandatory="是" Length="20">{新密码}</NewPassword>
        //</Document>
        protected int ChangeStudentPassword(OUDataInfo userInfo, string studentGuid, XmlNode xmlData)
        {
            IDBDataObject InfoData = (_dataDefine as BusinessStudentInfo).GetStudentInfoData(studentGuid);
            int result = -1;

            if (InfoData.ID == 0)
            {
                //No record found.
                result = -100;
            }
            else
            {
                string oldpassword = XmlNodeManage.GetSubValue(xmlData, "OldPassword");
                string newPassword = XmlNodeManage.GetSubValue(xmlData, "NewPassword");
                string databasePwd = InfoData["fStudentPassword"].ToString();

                if (string.Compare(databasePwd, oldpassword, false) != 0)
                {
                    //Original Password is not matching.
                    result = -101;
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(newPassword))
                    {
                        //New password is empty.
                        result = -102;
                    }
                    else
                    {
                        InfoData["fStudentPassword"] = newPassword;
                        result = InfoData.SaveData() ? 0 : 1;
                    }
                }
            }

            return result;
        }
        #endregion
        #endregion

        #region Get Data

        /// <summary>
        /// 根据学员标识获得学员基础信息
        /// </summary>
        /// <remarks>
        /// 应用标识：智慧驾培学事管理系统
        /// 模块分类：驾校运营
        /// 功能分类：学员管理
        /// 分类序号：1001
        /// 数据编号：ZHJP-BUSINESS-STUDENT-1001
        /// 数据类型：元数据
        /// 数据名称：学员信息
        /// 数据代码：BizStudentInfo
        /// 数据说明：学员基础信息
        /// </remarks>
        protected XmlNode GetStudentInfo(OUDataInfo userInfo, string studentGuid)
        {
            //if (!CheckPrivilege(UserInfo, "操作成员"))
            //    return null;

            IDBDataObject InfoData = (_dataDefine as BusinessStudentInfo).GetStudentInfoData(studentGuid);

            XmlNode xmlNotesInfoData = XmlNodeManage.GetDocumentNode(_taskGuid, studentGuid, DATATYPE_STUDENT_INFO);

            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentGuid", "GUID", InfoData["fStudentGuid"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentName", "TEXT", InfoData["fStudentName"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentSex", "TEXT", InfoData["fStudentSex"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentType", "TEXT", InfoData["fStudentType"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentID", "TEXT", InfoData["fStudentID"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentAge", "LONG", InfoData["fStudentAge"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentCode", "TEXT", InfoData["fStudentCode"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentMobile", "TEXT", InfoData["fStudentMobile"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentMail", "TEXT", InfoData["fStudentMail"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentAccount", "TEXT", InfoData["fStudentAccount"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentStatus", "TEXT", InfoData["fStudentStatus"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "SchoolGuid", "GUID", InfoData["fSchoolGuid"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "SchoolName", "TEXT", InfoData["fSchoolName"]);

            return xmlNotesInfoData;
        }

        /// <summary>
        /// 按学员降序后获得最新学员的学号，如果还没有学员则返回空.
        /// </summary>
        /// <remarks>
        /// 应用标识：智慧驾培学事管理系统
        /// 模块分类：驾校运营
        /// 功能分类：学员管理
        /// 分类序号：1004
        /// 数据编号：ZHJP-BUSINESS-STUDENT-1004
        /// 数据类型：复合数据
        /// 数据名称：最新学员的信息
        /// 数据代码：BizStudentInfoLastOne
        /// 数据说明：按学员降序后获得最新学员的学号，如果还没有学员则返回空
        /// </remarks>
        protected XmlNode GetLastStudentInfo(OUDataInfo userInfo, string studentGuid)
        {
            //if (!CheckPrivilege(UserInfo, "操作成员"))
            //    return null;

            IDBBigObjectSet InfoData = (_dataDefine as BusinessStudentInfo).GetLastStudentInfoData();

            XmlNode xmlNotesInfoData = XmlNodeManage.GetDocumentNode(_taskGuid, studentGuid, DATATYPE_STUDENT_LAST_INFO);
            InfoData.MoveTo(InfoData.DataCount - 1);

            XmlNodeManage.SetSubValue(xmlNotesInfoData, "SchoolGuid", "GUID", InfoData["fSchoolGuid"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "SchoolName", "TEXT", InfoData["fSchoolName"]); 
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentGuid", "GUID", InfoData["fStudentGuid"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentName", "TEXT", InfoData["fStudentName"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentSex", "TEXT", InfoData["fStudentSex"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentIdType", "TEXT", InfoData["fStudentIdType"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentIdCode", "TEXT", InfoData["fStudentIdCode"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentAge", "LONG", InfoData["fStudentAge"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentID", "TEXT", InfoData["fStudentID"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentMobile", "TEXT", InfoData["fStudentMobile"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentMail", "TEXT", InfoData["fStudentMail"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentAccount", "TEXT", InfoData["fStudentAccount"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentPassword", "TEXT", InfoData["fStudentPassword"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentStatus", "TEXT", InfoData["fStudentStatus"]);

            return xmlNotesInfoData;
        }


        /// <summary>
        /// 根据学号获得学员信息
        /// </summary>
        /// <remarks>
        /// 应用标识：智慧驾培学事管理系统 
        /// 模块分类：驾校运营
        /// 功能分类：学员管理 
        /// 分类序号：1002
        /// 数据编号：ZHJP-BUSINESS-STUDENT-1002
        /// 数据类型：复合数据 
        /// 数据名称：根据学号获得学员信息 
        /// 数据代码：BizStudentInfoByID 
        /// 数据说明：根据学员获得学员的基础信息，只支持GetData
        /// </remarks>
        protected XmlNode GetStudentInfoByID(OUDataInfo userInfo, string studentId)
        {
            //if (!CheckPrivilege(UserInfo, "操作成员"))
            //    return null;

            IDBDataObject InfoData = (_dataDefine as BusinessStudentInfo).GetStudentById(studentId);

            XmlNode xmlNotesInfoData = XmlNodeManage.GetDocumentNode(_taskGuid, studentId, DATATYPE_STUDENT_BYID);

            XmlNodeManage.SetSubValue(xmlNotesInfoData, "SchoolGuid", "GUID", InfoData["fSchoolGuid"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "SchoolName", "TEXT", InfoData["fSchoolName"]); 
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudengGuid", "GUID", InfoData["fStudentGuid"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentName", "TEXT", InfoData["fStudentName"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentCode", "TEXT", InfoData["fStudentCode"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentSex", "TEXT", InfoData["fStudentSex"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentType", "TEXT", InfoData["fStudentType"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentID", "TEXT", InfoData["fStudentID"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentAge", "LONG", InfoData["fStudentAge"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentMobile", "TEXT", InfoData["fStudentMobile"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentMail", "TEXT", InfoData["fStudentMail"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentAccount", "TEXT", InfoData["fStudentAccount"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentStatus", "TEXT", InfoData["fStudentStatus"]);

            return xmlNotesInfoData;
        }

        protected XmlNode GetStudentInfoByFinger(OUDataInfo userInfo, string fingerprinter)
        {
            //if (!CheckPrivilege(UserInfo, "操作成员"))
            //    return null;

            IDBDataObject InfoData = (_dataDefine as BusinessStudentInfo).GetStudentInfoByFingerprinter(fingerprinter);

            XmlNode xmlNotesInfoData = XmlNodeManage.GetDocumentNode(_taskGuid, fingerprinter, DATATYPE_GET_STUDENT_BY_FINGER);

            XmlNodeManage.SetSubValue(xmlNotesInfoData, "SchoolGuid", "GUID", InfoData["fSchoolGuid"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "SchoolName", "TEXT", InfoData["fSchoolName"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudengGuid", "GUID", InfoData["fStudentGuid"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentName", "TEXT", InfoData["fStudentName"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentCode", "TEXT", InfoData["fStudentCode"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentSex", "TEXT", InfoData["fStudentSex"]);
            XmlNodeManage.SetSubValue(xmlNotesInfoData, "StudentStatus", "TEXT", InfoData["fStudentStatus"]);

            return xmlNotesInfoData;
        }
        #endregion

        #region Transform Data

        /// <summary>
        /// 查询学员基础信息
        /// </summary>
        /// <remarks>
        /// 应用标识：智慧驾培学事管理系统
        /// 模块分类：驾校运营
        /// 功能分类：学员管理
        /// 分类序号：1003
        /// 数据编号：ZHJP-BUSINESS-STUDENT-1003
        /// 数据类型：查询返回
        /// 数据名称：学员信息查询
        /// 数据代码：BizStudentInfoQuery
        /// 数据说明：查询学员基础信息
        /// </remarks>
        protected XmlNode GetStudentList(OUDataInfo userInfo, XmlNode xmlParam)
        {

            string queryName = XmlNodeManage.GetSubValue(xmlParam, "StudentName");
            string querySex = XmlNodeManage.GetSubValue(xmlParam, "StudentSex");
            string queryID = XmlNodeManage.GetSubValue(xmlParam, "StudentID");
            string queryMobile = XmlNodeManage.GetSubValue(xmlParam, "StudentMobile");
            string queryStatus = XmlNodeManage.GetSubValue(xmlParam, "StudentStatus");
            string queryPageIndex = XmlNodeManage.GetSubValue(xmlParam, "PageIndex");
            string queryPageSize = XmlNodeManage.GetSubValue(xmlParam, "PageSize");


            IDBBigObjectSet students = (_dataDefine as BusinessStudentInfo).GetStudentList(queryName, querySex, queryID, queryMobile, queryStatus);
            Pagination dataPage = new Pagination(students);
            List<IDBDataObject> studentList = dataPage.GetPageDataSet(queryPageIndex, queryPageSize);
            queryPageIndex = dataPage.PageIndex.ToString();
            queryPageSize = dataPage.PageSize.ToString();

            XmlNode xmlQueryData = XmlNodeManage.GetDocumentNode(_taskGuid, "", DATATYPE_STUDENT_QUERY);

            //Add the paging nodes.
            XmlNodeManage.SetSubValue(xmlQueryData, "RecordCount", "LONG", students.DataCount);
            XmlNodeManage.SetSubValue(xmlQueryData, "PageSize", "LONG", queryPageSize);
            XmlNodeManage.SetSubValue(xmlQueryData, "PageIndex", "LONG", queryPageIndex);

            XmlNode studentRoot = XmlNodeManage.CreateNode("StudentList");
            XmlNode subNode;

            foreach (IDBDataObject student in studentList)
            {
                subNode = XmlNodeManage.CreateNode("StudentInfo");

                XmlNodeManage.SetSubValue(subNode, "StudentGuid", "GUID", student["fStudentGuid"]);
                XmlNodeManage.SetSubValue(subNode, "StudentName", "TEXT", student["fStudentName"]);
                XmlNodeManage.SetSubValue(subNode, "StudentSex", "TEXT", student["fStudentSex"]);
                XmlNodeManage.SetSubValue(subNode, "StudentType", "TEXT", student["fStudentType"]);
                XmlNodeManage.SetSubValue(subNode, "StudentID", "TEXT", student["fStudentID"]);
                XmlNodeManage.SetSubValue(subNode, "StudentAge", "LONG", student["fStudentAge"]);
                XmlNodeManage.SetSubValue(subNode, "StudentCode", "TEXT", student["fStudentCode"]);
                XmlNodeManage.SetSubValue(subNode, "StudentMobile", "TEXT", student["fStudentMobile"]);
                XmlNodeManage.SetSubValue(subNode, "StudentMail", "TEXT", student["fStudentMail"]);
                XmlNodeManage.SetSubValue(subNode, "StudentAccount", "TEXT", student["fStudentAccount"]);
                XmlNodeManage.SetSubValue(subNode, "StudentStatus", "TEXT", student["fStudentStatus"]);

                studentRoot.AppendChild(subNode);
            }
            xmlQueryData.AppendChild(studentRoot);
            return xmlQueryData;
        }

        #endregion

        #endregion
    }
}
